<template>
	<el-dialog draggable overflow :title="'财务审核'" v-model="visible" :width="1000" destroy-on-close
		@closed="$emit('closed')">
		<sk-upload v-model="form.attachments" :limit="10" draggable tip="" :disabled="true">
		</sk-upload>

		<el-form :model="form" :rules="rules" ref="dialogForm" label-width="100px" label-position="right">
			<el-row>
				<el-col :span="4">
					<el-form-item label="编号" prop="code">
						<el-input label="编号" v-model="form.code" disabled></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="4">
					<el-form-item label="入库日期" prop="in_date">
						<el-input v-model="form.in_date" disabled></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="4">
					<el-form-item label="供应商" prop="company">
						<el-input v-model="form.company.name" disabled></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="4">
					<el-form-item label="是否含税" prop="tax_id">
						<el-switch v-model="form.tax_id" :active-value="1" :inactive-value="0" disabled></el-switch>
					</el-form-item>
				</el-col>
				<el-col :span="8">
					<el-form-item label="备注" prop="remark">
						<el-input v-model="form.remark" disabled></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="财务备注" prop="financeremark">
						<el-input v-model="form.financeremark"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
			<sc-VxeTable ref="xGrid1" :gridEvts="gridEvents" :data="form.details" :gridOps="gridOps"
				:tablecode="'storageActionPurchaseSave_finance'">
			</sc-VxeTable>
		</el-form>
		<template #footer>
			<el-button @click="visible = false">取 消</el-button>
			<el-button type="primary" :loading="isSaveing" @click="submit()">审 核</el-button>
		</template>
	</el-dialog>
</template>

<script>
import skAutoChoose from "@/components/skAutoChoose";
export default {
	emits: ["success", "closed"],
	components: { skAutoChoose },
	data() {
		return {
			gridEvents: {},
			gridOps: {
				height: 200,
			},
			form: {
				company: {},
				attachments: [],
				details: [],
			},
			rules: {
			},
			visible: false,
			isSaveing: false,
		};
	},
	mounted() { },
	methods: {
		//显示
		open() {
			this.visible = true;
			return this;
		},
		//表单提交方法
		submit() {
			this.isSaveing = true;
			this.$API.purchase.storage.faudit.post(
				{ id: this.form.id, financeremark: this.form.financeremark }
			).then((res) => {
				if (res.code == 200) {
					this.$emit("success", this.form, this.mode);
					this.visible = false;
					this.$message.success("操作成功");
				}
			}).finally(() => {
				this.isSaveing = false;
			});
		},
		async getItems(id) {
			var res = await this.$API.purchase.storage.list.get({
				filter: [{ id: id }],
			});
			if (res.code == 200) {
				this.form = { ...res.data.rows[0], details: res.data.rows };
			}
		},
		//表单注入数据
		setData(data) {
			this.getItems(data.id);
		},
	},
};
</script>

<style></style>
